<template>
	<hyb-page title="下单信息填写">
		<template v-slot:body>
			<view class="gui-margin-x-middle gui-margin-top-middle" v-if="info.x_id">
				<!-- 机构及服务信息部分 -->
				<view class="gui-bg-white gui-border-radius-large">
					<view class="gui-text gui-padding gui-color-gray gui-bold">机构及服务信息</view>
					<!-- 机构信息 -->
					<view class="gui-border-t">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								机构
							</view>
							<view class="gui-flex gui-align-items-center">{{info.shangjia.s_name}}</view>
						</view>
					</view>
					<!-- 产品信息 -->
					<view class="gui-border-t">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								产品
							</view>
							<view class="gui-flex gui-align-items-center">{{info.x_name}}</view>
						</view>
					</view>
					<!-- 单价信息 -->
					<view class="gui-border-t">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								单价
							</view>
							<view class="gui-flex gui-align-items-center">
								{{info.x_guigecontent[guiges].price}}({{info.x_guigecontent[guiges].name}})
							</view>
						</view>
					</view>
					<!-- 医院信息 -->
					<view class="gui-border-t" @tap="showCompany()">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								医院
							</view>
							<view class="gui-flex gui-align-items-center"><text class="gui-text"
									:class="{'gui-color-gray':!formData.company}">{{formData.company||'请选择'}}</text><text
									class="gui-icons gui-block gui-color-gray gui-text">&#xe601;</text></view>
						</view>
					</view>
					<!-- 科室信息 -->
					<view class="gui-border-t">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								科室
							</view>

							<input style="text-align: right;" type="text" placeholder="请填写内容" v-model="formData.dept" />

						</view>
					</view>
					<!-- 床号信息 -->
					<view class="gui-border-t">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								床号
							</view>
							<input style="text-align: right;" type="text" placeholder="请填写内容"
								v-model="formData.bed_num" />
						</view>
					</view>
				</view>

				<!-- 下单人信息部分 -->
				<view class="gui-bg-white gui-border-radius-large gui-margin-top">
					<view class="gui-text gui-padding gui-color-gray gui-bold">下单人信息</view>
					<!-- 下单人姓名 -->
					<view class="gui-border-t">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								下单人
							</view>
							<input style="text-align: right;" type="text" placeholder="请填写内容"
								v-model="formData.u_name" />
						</view>
					</view>
					<!-- 联系电话 -->
					<view class="gui-border-t">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								联系电话
							</view>
							<input style="text-align: right;" type="text" placeholder="请填写内容"
								v-model="formData.u_phone" />
						</view>
					</view>
				</view>

				<!-- 服务对象信息部分 -->
				<view class="gui-bg-white gui-border-radius-large gui-margin-top">
					<view class="gui-text gui-padding gui-color-gray gui-bold">服务对象</view>
					<!-- 姓名 -->
					<view class="gui-border-t">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								姓名
							</view>
							<input style="text-align: right;" type="text" placeholder="请填写内容" v-model="formData.name" />
						</view>
					</view>
					<!-- 性别 -->
					<view class="gui-border-t" @tap="showSexPopup">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								性别
							</view>
							<view class="gui-flex gui-align-items-center"><text class="gui-text"
									:class="{'gui-color-gray':!formData.sex}">{{formData.sex||'请选择'}}</text><text
									class="gui-icons gui-block gui-color-gray gui-text">&#xe601;</text></view>
						</view>
					</view>
					<!-- 年龄 -->
					<view class="gui-border-t">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								年龄
							</view>
							<input style="text-align: right;" type="text" placeholder="请填写内容" v-model="formData.age" />
						</view>
					</view>
					<!-- 手机号 -->
					<view class="gui-border-t">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								手机号
							</view>
							<input style="text-align: right;" type="text" placeholder="请填写内容"
								v-model="formData.phone" />
						</view>
					</view>
					<!-- 身份证号 -->
					<view class="gui-border-t" v-if="false">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								身份证号
							</view>
							<input style="text-align: right;" type="text" placeholder="请填写内容"
								v-model="formData.id_num" />
						</view>
					</view>
					<!-- 与服务对象的关系 -->
					<view @tap="showTypes()" class="gui-border-t">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								与服务对象的关系
							</view>

							<view class="gui-flex gui-align-items-center"><text class="gui-text"
									:class="{'gui-color-gray':!formData.type}">{{formData.type||'请选择'}}</text><text
									class="gui-icons gui-block gui-color-gray gui-text">&#xe601;</text></view>
						</view>
					</view>

				</view>

				<!-- 服务时间信息部分 -->
				<view class="gui-bg-white gui-border-radius-large gui-margin-top">
					<view class="gui-text  gui-padding gui-color-gray gui-bold">服务时间</view>
					<!-- 服务开始时间 -->
					<view @tap="popup" class="gui-border-t">
					    <view class="gui-flex gui-align-items-center gui-space-between gui-padding">
					        <view class="gui-text">服务开始时间</view>
					        <view class="gui-flex gui-align-items-center">
					            <text class="gui-text" :class="{'gui-color-gray':!fa_fwtime}">
					                {{fa_fwtime || '选择服务时间'}}
					            </text>
					            <text class="gui-icons gui-block gui-color-gray gui-text">&#xe601;</text>
					        </view>
					    </view>
					</view>
					<!-- 服务天(次)数 -->
					<view class="gui-border-t">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								服务天(次)数
							</view>
							<view class="gui-flex gui-align-items-center">{{nums[0]}}</view>
						</view>
					</view>
					<!-- 服务结束时间 -->
					<view class="gui-border-t">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								服务结束时间
							</view>
							<view class="gui-flex gui-align-items-center">{{end_time}}</view>
						</view>
					</view>

				</view>

				<!-- 签字图片部分 -->
				<view class="gui-bg-white gui-border-radius-large gui-margin-top">
					<view @tap="showSign()">
						<view class=" gui-flex  gui-align-items-center gui-space-between gui-padding">
							<view class="gui-text">
								签字图片
							</view>
							<view class="gui-flex gui-align-items-center">
								<image
									style="height: 160rpx;width: 160rpx;border-radius: 10rpx;background-color: rgba(99,99,99,0.5)"
									:src="sign||''">
								</image>
								<text class="gui-icons gui-block gui-color-gray gui-text">&#xe601;</text>
							</view>
						</view>
					</view>
				</view>
			</view>

			<!-- 支付组件 -->
			<hyb-pay :yhq="info.x_youhuiquanstatus" :max_jifen="info.x_jifen" :gujia="info.x_gujia"
				:dingjin_money="info.x_min_money" :money="money" :discount_money="discount_money" @confirm="confirm">

				<view class="gui-dark-bg-level-3 gui-padding gui-margin-top">
					<gui-radio @change="changeChecked" :checked="checked" v-model="checked">
						已阅读并同意签署 <text class="gui-primary-color" @tap.stop="privacy()">《患者陪护服务协议》</text>
					</gui-radio>
				</view>
			</hyb-pay>

			<!-- 隐私协议弹窗 -->
			<hyb-privacy ref="privacy" title="患者陪护服务协议" :content="privacyContent" @change="changeChecked"
				v-model="checked"></hyb-privacy>

			<!-- 医院选择弹窗 -->
			<gui-popup ref="companyPopup" position="bottom">
				<view class="gui-border-top-radius-large gui-overflow-hidden depts">
					<scroll-view style="max-height: 60vh;" scroll-y>
						<view class="gui-bg-white gui-padding">
							<gui-select-list @change="changeCompany" :items="companys"></gui-select-list>
						</view>
					</scroll-view>
				</view>
				<gui-iphone-bottom :customClass="['gui-bg-white', 'gui-dark-bg-level-3']"></gui-iphone-bottom>

			</gui-popup>


			<!--只要显示这个组件会优先使用日历 -->
			<hyb-calendar-popup v-if="$store.state.base.show_base.yu_yue_sj_type" v-model="fa_fwtime"
				ref="calendarPopup" title="选择服务时间"></hyb-calendar-popup>

			<!-- 服务时间选择弹窗 -->
			<gui-popup ref="timePopup" position="bottom">
				<view class="gui-bg-white gui-padding gui-text-center gui-text gui-border-b">
					选择服务时间
				</view>
				<view class="gui-bg-gray">
					<view class="gui-bg-white gui-padding">
						<gui-switch-navigation :titleClass="['gui-primary-text']"
							:activeLineClass="['gui-nav-scale','gui-gtbg-red', 'gui-gtbg-black']" isCenter
							:items="dates" :size="200" activeLineWidth="160rpx" activeDirection="center"
							textAlign="center" :currentIndex="dateIndex" @change="datechange" style="width: 100%">
						</gui-switch-navigation>
					</view>

					<scroll-view scroll-y style="max-height: 45vh;">
						<view class="gui-bg-gray gui-flex gui-wrap">
							<view v-for="(item,index) in times" :key="index" style="flex:0 0 33%"
								class="gui-flex gui-justify-content-center">
								<view @tap="timeSelect(index)"
									:class="timeIndex == index?['gui-bg-red','gui-color-white']:['gui-bg-white']"
									class="gui-text-center gui-padding-small gui-border-radius-large gui-margin-x gui-margin-top">
									<view class="gui-text-small" :class="item.times == 0?['gui-color-gray']:[]">
										{{item.start}}-{{item.end}}
									</view>
									<view class="gui-text-small gui-margin-top-small"
										:class="timeIndex == index?['gui-color-white']:item.times==0?['gui-color-gray']:['gui-color-red']">
										剩余{{item.times}}次
									</view>
								</view>
							</view>
						</view>
					</scroll-view>

					<view class="gui-padding gui-margin-top">
						<button type="default" class="gui-button gui-bg-red gui-noborder" @tap.prevent="comfirDate"
							style="border-radius:50rpx;">
							<text class="gui-color-white gui-button-text">确定</text>
						</button>
					</view>
				</view>
			</gui-popup>

			<!-- 科室选择弹窗 -->
			<gui-popup ref="deptPopup" position="bottom">
				<view class="gui-border-top-radius-large gui-overflow-hidden depts">
					<scroll-view style="max-height: 60vh;" scroll-y>
						<view class="gui-bg-white gui-padding">
							<gui-select-list @change="changeDept" :items="depts"></gui-select-list>
						</view>
					</scroll-view>
				</view>
				<gui-iphone-bottom :customClass="['gui-bg-white', 'gui-dark-bg-level-3']"></gui-iphone-bottom>

			</gui-popup>

			<!-- 与服务对象关系选择弹窗 -->
			<gui-popup ref="typePopup" position="bottom">
				<view class="gui-border-top-radius-large gui-overflow-hidden depts">
					<scroll-view style="max-height: 60vh;" scroll-y>
						<view class="gui-bg-white gui-padding">
							<gui-select-list @change="changeType" :items="types"></gui-select-list>
						</view>
					</scroll-view>
				</view>
				<gui-iphone-bottom :customClass="['gui-bg-white', 'gui-dark-bg-level-3']"></gui-iphone-bottom>
			</gui-popup>

			<!-- 性别选择弹窗 -->
			<gui-popup ref="sexPopup" position="bottom">
				<view class="gui-border-top-radius-large gui-overflow-hidden depts">
					<scroll-view style="max-height: 60vh;" scroll-y>
						<view class="gui-bg-white gui-padding">
							<gui-select-list @change="changeSex" :items="sexOptions"></gui-select-list>
						</view>
					</scroll-view>
				</view>
				<gui-iphone-bottom :customClass="['gui-bg-white', 'gui-dark-bg-level-3']"></gui-iphone-bottom>
			</gui-popup>

			<!-- 签字组件 -->
			<hyb-sign @change="changeSign" v-model="sign" ref="sign"></hyb-sign>
			<!-- 上传组件 -->
			<hyb-upload hide ref="upload" v-model="formData.sign"></hyb-upload>
		</template>
	</hyb-page>
</template>

<script>
	import moment from 'moment';
	import pay from '../../../../custom/pay';
	export default {
		data() {
			return {
				sign: '',
				checked: false,
				formData: {
					company: '',
					dept: '',
					bed_num: '',
					u_name: '',
					u_phone: '',
					name: '',
					sex: '',
					age: '',
					phone: '',
					id_num: '',
					type: '',
					sign: ''
				},
				end_time: '',
				bed_num: '',
				companys: [],
				depts: [],
				types: [{
					title: '本人'
				}, {
					title: '配偶'
				}, {
					title: '子女'
				}, {
					title: '孙子孙女'
				}, {
					title: '父母'
				}, {
					title: '祖父母'
				}, {
					title: '亲友'
				}, {
					title: '兄弟姐妹'
				}, {
					title: '朋友'
				}, {
					title: '其他'
				}],
				sexOptions: [{
						title: '男'
					},
					{
						title: '女'
					}
				],
				deptIndex: -1,
				typeIndex: -1,
				id_card: "",
				fb_attributes: {},
				info: {},
				address: {},
				guige: -1,
				num: 1,
				tag: "pay",
				jishi: {
					y_id: 0
				},
				dates: [],
				dateIndex: 0,
				timeIndex: -1,
				times: [],
				x_id: 0,
				is_vip: false,
				money: 0,
				discount_money: 0,
				userinfo: {},
				guiges: [],
				nums: [],
				yh_bei_zhu: '',
				pay_s_id: 0,
				idCard1: "https://img-cdn-tc.dcloud.net.cn/uploads/article/20210107/e53bf48607dcf795ab78e419dc5cf432.png",
				fa_fwtime: ''
			}
		},
		watch: {
		    fa_fwtime(newVal) {
		        if (newVal) {
		            const [date, timeRange] = newVal.split(' ');
		            this.end_time = moment(date).add(this.nums[0], 'days').format("YYYY-MM-DD") + ' ' + timeRange;
		        }
		    }
		},
		async onLoad(options) {

			this.userinfo = await uni.gPost("user/info");
			uni.storage.set("userinfo", this.userinfo);

			if (this.userinfo.huiyuan) {
				this.is_vip = true;
			}

			this.x_id = options.x_id;
			if (options.guige != undefined) {
				this.guige = options.guige;
			}

			if (options.num) {
				this.num = options.num;
			}


			if (options.guiges) {
				this.guiges = options.guiges.split(",");
			}

			if (options.nums) {
				this.nums = options.nums.split(",");
			}


			uni.gPost("fuwu/info", {
				x_id: this.x_id
			}).then((data) => {
				this.info = data;
				if (this.info.shangjia.depts) this.depts = this.info.shangjia.depts.split(',').map(val => {
					return {
						title: val
					}
				})
				if (this.$store.state.base.show_base.fuwu_gui_ge == 1) {
					let money = 0;
					this.nums.forEach((num, index) => {
						money += (this.info.x_guigecontent[this.guiges[index]]["price"] * num);
					})
					this.money = money;

					if (this.is_vip) {
						let discount_money = 0;
						this.nums.forEach((num, index) => {
							discount_money += ((this.info.x_guigecontent[this.guiges[index]]["price"] -
									this.info.x_guigecontent[this.guiges[index]]["vip_price"]) *
								num);
						})
						this.discount_money = discount_money;
					}

				} else {
					if (this.guige == -1) {
						this.money = this.info.x_jiage * this.num;

					} else {
						this.money = this.info.x_guigecontent[this.guige]["price"] * this.num;
					}

					if (this.is_vip) {
						if (this.guige == -1) {
							if (this.info.vip_jiage > 0) {
								this.discount_money = (this.info.x_jiage - this.info.vip_jiage) * this.num;
							} else {
								this.discount_money = (this.info.x_jiage - this.info.x_jiage * this.userinfo[
									"huiyuan"]["h_zhekou"]) * this.num;
							}

						} else {
							if (this.info.x_guigecontent[this.guige]["vip_price"] > 0) {

								this.discount_money = (this.info.x_guigecontent[this.guige]["price"] - this
									.info
									.x_guigecontent[this.guige]["vip_price"]) * this.num

							} else {
								this.discount_money = (this.info.x_guigecontent[this.guige]["price"] - this
										.info
										.x_guigecontent[this.guige]["price"] * this.userinfo["huiyuan"][
											"h_zhekou"
										]
									) * this
									.num
							}

						}
					}
				}


			})

			uni.gPost("address/list").then((list) => {
				if (list.length > 0) {
					this.address = list[0]
				}
			})
			const location = await uni.location.getLocation()
			uni.gPost("shangjia/list", {
				location: location ? {
					latitude: location.latitude,
					longitude: location.longitude
				} : null,
				flag: 1
			}).then((list) => {
				this.companys = list.map((val) => {
					return {
						img: val.s_thumb,
						title: val.s_name + (val.distance ? "(" + val.distance + "公里)" : ''),
						s_id: val.s_id
					}
				})
			})

			uni.$on(this.tag, (address) => {
				this.address = address;
			})


			uni.$on("choose_jishi", (jishi) => {
				this.jishi = jishi;
			})
		},

		computed: {
			base: () => {
				return uni.storage.get("base")
			},
			privacyContent: function() {
				if (!this.info || !this.info.shangjia) return ""
				if (this.sign) {
					return this.info.shangjia.privacy +
						`<p><img style="width:200px !important;height:200px !important;position:absolute;bottom:0;right:0；" src="${this.sign}"/></p>`
				}
				return this.info.shangjia.privacy
			}
		},

		methods: {
			changeChecked(val) {
				console.log(val)
				this.checked = val
			},

			base64ToFile(base) {
				let url = base
				// #ifdef H5
				const byteCharacters = atob(base.replace('data:image/png;base64,', ''));
				const byteNumbers = new Array(byteCharacters.length);
				for (let i = 0; i < byteCharacters.length; i++) {
					byteNumbers[i] = byteCharacters.charCodeAt(i);
				}
				const byteArray = new Uint8Array(byteNumbers);
				const blob = new Blob([byteArray], {
					type: "image/png"
				});
				//blob-->url
				let binaryData = [];
				binaryData.push(blob);
				url = URL.createObjectURL(new Blob(binaryData));
				// #endif
				return {
					name: '签字.png',
					url: url
				};
			},
			privacy() {
				this.$refs.privacy.open()
			},
			changeSign(url) {
				this.sign = url
			},
			showSign() {
				this.$refs.sign.popup()
			},

			changeType(index) {
				this.formData.type = this.types[index].title
				this.$refs.typePopup.close()
			},

			changeCompany(index) {
				this.pay_s_id = this.companys[index].s_id
				this.formData.company = this.companys[index].title
				this.$refs.companyPopup.close()
			},

			showTypes() {
				this.$refs.typePopup.open()
			},
			changeDept(index) {
				this.formData.dept = this.depts[index].title
				this.$refs.deptPopup.close()
			},

			showCompany() {
				this.$refs.companyPopup.open()
			},

			showDepts() {
				this.$refs.deptPopup.open()
			},

			goAddress1() {
				uni.openLocation({
					latitude: parseFloat(this.info.shangjia.latitude),
					longitude: parseFloat(this.info.shangjia.longitude)
				})
			},

			format_money(val) {
				return parseFloat(val).toFixed(2);
			},

			timeSelect(index) {
			    if (this.times[index].times > 0) {
			        this.timeIndex = index;
			        this.fa_fwtime = this.dates[this.dateIndex].id + ' ' + this.times[this.timeIndex].start + '-' + this.times[this.timeIndex].end;
			        // 这行会被 watch 自动处理，所以可以省略
			        // this.end_time = moment(this.dates[this.dateIndex].id).add(this.nums[0], 'days').format("YYYY-MM-DD") + ' ' + this.times[this.timeIndex].start + '-' + this.times[this.timeIndex].end;
			    } else {
			        uni.showToast({
			            title: "已订完!",
			            icon: 'none'
			        })
			    }
			},

			comfirDate() {

				if (this.timeIndex == -1) {
					uni.showToast({
						title: "请选择服务时间",
						icon: 'none'
					})
				} else {
					this.$refs.timePopup.close();
				}
			},

			datechange(e) {
				this.dateIndex = e;
				this.timeIndex = -1;

				uni.gPost("fuwu/times", {
					x_id: this.x_id,
					date: this.dates[this.dateIndex].id
				}).then((times) => {
					this.times = times;
				})
			},

			getDay(day) {
				return ['日', '一', '二', '三', '四', '五', '六'][day];
			},

			popup() {
				if (this.$refs.calendarPopup) {
					this.$refs.calendarPopup.open()
				} else {
					if (this.dates.length == 0) {
						let date = null;
						for (let i = 0; i < 30; i++) {
							date = moment().add(i, 'days');
							this.dates.push({
								id: date.format("YYYY-MM-DD"),
								name: "星期" + this.getDay(date.day()) + "\n" + date.format("YYYY-MM-DD")
							});
						}
						this.datechange(0);
					}
					console.log(this.dates);
					this.$refs.timePopup.open();
				}
			},

			goJishi() {
				uni.navigateTo({
					url: "/hyb_o2o/jishi/list/list?tag=1"
				})
			},

			goAddress() {
				uni.navigateTo({
					url: "/hyb_o2o/address/address?flag=1&tag=" + this.tag
				})
			},

			async confirm(pay_type, jifen, yhq_id, jb_yusuan, pay_u_id) {
				console.log(this.base.show_base.yu_yue_sj)
				let msg = ""
				if (!this.formData.company) {
					msg = "请填写医院"
				} else if (!this.formData.dept) {
					msg = "请填写科室"
				} else if (!this.formData.u_name) {
					msg = "请填写下单人"
				} else if (!this.formData.u_phone) {
					msg = "请填写联系电话"
				} else if (!this.formData.name) {
					msg = "请填写姓名"
				} else if (!this.formData.sex) {
					msg = "请选择性别"
				} else if (!this.formData.age) {
					msg = "请填写年龄"
				} else if (!this.formData.phone) {
					msg = "请填写手机号"
				} else if (!this.formData.id_num && false) {
					msg = "请填写身份证号"
				} else if (!this.formData.type) {
					msg = "请选择与服务对象的关系"
				} else if (!this.fa_fwtime && this.base.show_base.yu_yue_sj) {
					msg = "请选择服务开始时间"
				} else if (!this.sign) {
					msg = "请签字"
				} else if (!this.checked) {
					msg = "请先同意协议"
				}

				if (msg) {
					uni.showToast({
						title: msg,
						icon: "none"
					})
				} else {
					const file = this.base64ToFile(this.sign)
					const urls = await this.$refs.upload.uploadAsync(file)
					this.formData.sign = urls[0]


					if (this.$store.state.base.show_base.fuwu_gui_ge == 1) {
						uni.$pay.pay("pay/fuwu", {
							pay_u_id: pay_u_id,
							id_card: this.id_card,
							xq_uid: this.$store.state.xiaoqu ? this.$store.state.xiaoqu.uid : "",
							fb_attributes: this.fb_attributes,
							jifen: jifen,
							yhq_id: yhq_id,
							x_id: this.x_id,
							d_id: this.address.d_id,
							guiges: this.guiges,
							nums: this.nums,
							y_id: this.jishi.y_id,
							yh_bei_zhu: this.yh_bei_zhu,
							date: this.base.show_base.yu_yue_sj == 1 ? this.fa_fwtime.split(' ')[0] : null,
							time: this.base.show_base.yu_yue_sj == 1 ? this.fa_fwtime.split(' ')[1] : null,
							jb_yusuan: jb_yusuan,
							form_data: this.formData,
							pay_s_id: this.pay_s_id
						}, pay_type).then(() => {
							uni.redirectTo({
								url: "/hyb_o2o/inner/pages/fabu/list?tag=yh"
							})
						}).catch((e) => {
							console.log(e)
						})
					} else {
						uni.$pay.pay("pay/fuwu", {
							id_card: this.id_card,
							xq_uid: this.$store.state.xiaoqu ? this.$store.state.xiaoqu.uid : "",
							fb_attributes: this.fb_attributes,
							jifen: jifen,
							yhq_id: yhq_id,
							x_id: this.x_id,
							d_id: this.address.d_id,
							guige: this.guige,
							num: this.num,
							y_id: this.jishi.y_id,
							yh_bei_zhu: this.yh_bei_zhu,
							date: this.base.show_base.yu_yue_sj == 1 ? this.dates[this.dateIndex].id : null,
							time: this.base.show_base.yu_yue_sj == 1 ? (this.times[this.timeIndex].start +
								"-" +
								this
								.times[this.timeIndex].end) : null,
							jb_yusuan: jb_yusuan,
							form_data: this.formData,
							pay_s_id: this.pay_s_id
						}, pay_type).then(() => {
							uni.redirectTo({
								url: "/hyb_o2o/inner/pages/fabu/list?tag=yh"
							})
						}).catch((e) => {
							console.log(e)
						})
					}


				}
			},
			showSexPopup() {
				this.$refs.sexPopup.open()
			},
			changeSex(index) {
				this.formData.sex = this.sexOptions[index].title
				this.$refs.sexPopup.close()
			}
		}
	}
</script>

<style scoped>
	.depts>>>.gui-select-list-title {
		font-size: 30rpx;
		color: #666 !important;
		font-weight: 500 !important;
	}
</style>
